<template>
  <div class="warehouse">
    <el-row class="head fff">
      <el-form
        :inline="true"
        :model="searchForm"
        label-position="top"
        class="search"
      >
        <el-col :span="6">
          <el-form-item label="承运商编号">
            <el-input
              v-model="searchForm.like_code"
              placeholder="请输入"
            /> </el-form-item></el-col>
        <el-col :span="6">
          <el-form-item label="承运商名称">
            <el-input
              v-model="searchForm.like_name"
              placeholder="请输入"
            /> </el-form-item></el-col>
        <el-col :span="6">
          <el-form-item label="联系人">
            <el-input
              v-model="searchForm.like_personName"
              placeholder="请输入"
            /> </el-form-item></el-col>
        <el-col :span="6" class="submit">
          <el-form-item>
            <el-button type="primary" @click="onSubmit">搜索</el-button>
            <el-button @click="reset">重置</el-button>
          </el-form-item></el-col>
      </el-form>
    </el-row>
    <el-row class="table fff">
      <div v-if="isNowData" class="now-data">
        <span class="imgIcon" /><span style="color: #b5abab;">暂无数据</span>
      </div>
      <template v-else>
        <el-table
          :data="tableData.records"
          stripe
          border
          :row-style="{}"
          :header-cell-style="{
            background: '#f9f6ee',
            borderColor: '#f5efee!important',
            padding: '10px 0',
          }"
          :cell-style="{ borderColor: '#f5efee!important', padding: '10px 0' }"
        >
          <el-table-column label="序号" width="68" align="center">
            <template v-slot="{ $index }">{{ $index + 1 }}</template>
          </el-table-column>
          <el-table-column
            prop="code"
            label="承运商编号"
            align="center"
            width="160"
          />
          <el-table-column
            prop="name"
            label="承运商名称"
            align="center"
            width="160"
          />
          <el-table-column
            prop="personName"
            label="联系人"
            align="center"
            width="160"
          />
          <el-table-column
            prop="phone"
            label="联系人电话"
            align="center"
            width="160"
          />
          <el-table-column
            prop="email"
            label="联系邮箱"
            align="center"
            width="280"
          />
          <el-table-column
            prop="location"
            label="省/市/区"
            align="center"
            width="280"
          />
          <el-table-column
            prop="address"
            label="详细地址"
            align="center"
            width="350"
          />
          <el-table-column
            prop="updateTime"
            label="更新时间"
            align="center"
            width="200"
          />
        </el-table>
      </template>
    </el-row>
  </div>
</template>

<script>
import { getCarrierList } from '@/api/carrier'
export default {
  data() {
    return {
      isNowData: true,
      searchForm: {
        current: 1,
        size: 10,
        like_code: null,
        like_name: null,
        like_personName: null
      },
      tableData: {}
    }
  },
  created() {
    this.getCarrierList()
  },
  methods: {
    async getCarrierList() {
      const { data } = await getCarrierList(this.searchForm)
      this.isNowData = !data.records.length
      this.tableData = data
    },
    onSubmit() {
      this.searchForm.current = 1
      this.getCarrierList()
    },
    reset() {
      this.searchForm.like_code = null
      this.searchForm.like_name = null
      this.searchForm.like_personName = null
      this.onSubmit()
    }
  }
}
</script>

<style lang="scss" scoped>
.warehouse {
  .table {
    padding: 0;
    margin-top: 20px;
    .add {
      padding: 20px 30px;
      border-bottom: 1px solid #f5efee;
    }
    .operate {
      color: #ffb200;
      cursor: pointer;
      &:hover {
        color: #ff8e00;
      }
      &.center {
        margin: 0 20px;
      }
    }
  }
}
</style>
